#ifndef __CAP_TEST_H__
#define __CAP_TEST_H__

#define CAPTEST_CHANNEL_LEFT	(0x1 << 0)
#define CAPTEST_CHANNEL_RIGHT (0x1 << 1)

#define CAPTEST_START					0
#define CAPTEST_COMPLETE			1
#define CAPTEST_TIMEOUT				2
#define CAPTEST_ERR_HW				3

#define CAPTEST_OK						4
#define CAPTEST_SHORT					5
#define CAPTEST_OPEN					6
#define CAPTEST_OVERLIMIT			7
#define CAPTEST_ERR_PARAM			8

#define DISCHG_RIGHT_ON()							HAL_GPIO_WritePin(DISCHG_SWCTL1_GPIO_Port, DISCHG_SWCTL1_Pin, GPIO_PIN_SET)
#define DISCHG_RIGHT_OFF()						HAL_GPIO_WritePin(DISCHG_SWCTL1_GPIO_Port, DISCHG_SWCTL1_Pin, GPIO_PIN_RESET)

#define DISCHG_LEFT_ON()							HAL_GPIO_WritePin(DISCHG_SWCTL2_GPIO_Port, DISCHG_SWCTL2_Pin, GPIO_PIN_SET)
#define DISCHG_LEFT_OFF()							HAL_GPIO_WritePin(DISCHG_SWCTL2_GPIO_Port, DISCHG_SWCTL2_Pin, GPIO_PIN_RESET)

void CapTest_Initialize(void);
void CapTest_Callback(void);
void CapTest_SaveVoltSel(unsigned char sel);
unsigned char CapTest_Start(unsigned char channel, float low_limit, float high_limit, float current, float dv, float *cap, unsigned int timeout);
unsigned char CapTest_Start2(unsigned char channel, float low_limit, float high_limit, float current, float dv, float *cap, unsigned int timeout);
unsigned char CapTest_GetValue(float low_limit, float high_limit, float current, float dv, float *cap);
void HAL_TIM_PeriodCallback(void);
void HAL_TIM_IC_CCaptureCallback(void);
void CapTest_PrepareCharge(float current);

#endif
